<!-- 百人&棋牌(飞机) -->
<template>
  <el-dialog v-if="props.show" :model-value="props.show" :title="'【百人场】'+ data.game_name" :close-on-click-modal="false" :close-on-press-escape="false"
    top="12vh" width="1050px" @close="onHideDetails">
    <div class="dialogMaxHeight" :class="props.showDisable ? 'disableUser' : ''">
      <el-form ref="ruleFormRef" :model="data" :inline="true" :rules="rules">
        <form-item title="游戏名称" :pass="true" value="game_name">
          <el-input class="width240" type="text" v-model="data.game_name" placeholder="请输入游戏名称" clearable disabled />
        </form-item>
        <form-item title="商户" :pass="true" value="agent_id" v-if="data.agent_id">
          <el-select v-model="data.agent_id" placeholder="请选择" filterable @change="chooseOperator">
            <el-option v-for="item in indexStore.agentArray" :key="item.value"
              :label="'【' + item.value + '】' + item.label" :value="item.value" />
          </el-select>
        </form-item> 
        <form-item title="房间最大人数" :pass="true" value="a_hundred_num">
          <el-input-number v-model="data.a_hundred_num" :min="0" :max="99999999999999999999" :precision="0"
            placeholder="房间最大人数" clearable controls-position="right" />
        </form-item>
        <form-item title="游戏水位" :pass="true" value="pool" v-if="data.agent_id">
          <el-input-number v-model="data.pool" :min="-99999999999999999999" :max="99999999999999999999" :precision="0"
            placeholder="游戏水位" clearable controls-position="right" />
        </form-item>
        <form-item title="抽水比例" :pass="true" value="a_hundred_pump">
          <el-input-number v-model="data.a_hundred_pump" :min="0" :max="100" :precision="4" placeholder="抽水比例" clearable
            controls-position="right"/>%
        </form-item>
        <form-item title="利润率" :pass="true" value="a_hundred_profitmargin">
          <el-input-number v-model="data.a_hundred_other_details.a_hundred_profitmargin" :min="0" :max="100" :precision="0" placeholder="抽水比例" clearable
            controls-position="right" />%
        </form-item>
        <form-item title="超长模式触发概率" :pass="true" value="a_hundred_supermoderate">
          <el-input-number v-model="data.a_hundred_other_details.a_hundred_supermoderate" :min="0" :max="100"
            :precision="4" placeholder="超长模式触发概率" clearable controls-position="right" />%
        </form-item>
        <form-item title="正常模式玩家跑光后" :pass="true" value="a_hundred_normalmode" :subtract="props.showDisable?false:true" @addItem="addNormalmode"
          @reduceItem="reduceNormalmode" style="height: auto; position: relative">
          <div class="flexWrap marginT5" v-for="(item, index) in data.normalmodeList" :key="index">
            倍数下限:
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="4"
              class="width150 marginR10" placeholder="倍数下限" clearable :controls="false" />
            倍数上限:
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="4"
              class="width150 marginR10" placeholder="倍数上限" clearable :controls="false" />
            下限百分比:
            <el-input-number v-model="item.percentMin" :min="0" :max="99999999999999999999" :precision="0"
              class="width150" placeholder="下限百分比" clearable :controls="false" />
              <span class="marginR10">%</span>
            上限百分比:
            <el-input-number v-model="item.percentMax" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginT5" placeholder="上限百分比" clearable :controls="false" />%
          </div>
        </form-item>
        <form-item title="超长模式玩家跑光随机倍数" :pass="true" value="a_hundred_supermode">
          <div class="flexWrap" v-for="(item, index) in data.supermodeList" :key="index">
            倍数下限:
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR20" placeholder="倍数下限" clearable :controls="false" />
            倍数上限:
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0" class="width150"
              placeholder="倍数上限" clearable :controls="false" />
          </div>
        </form-item>
        <form-item title="机器人数量" :pass="true" value="a_robot_hundred_num" :subtract="props.showDisable?false:true" @addItem="addRobotNum"
          @reduceItem="reduceRobotNum" style="height: auto; position: relative">
          下注模式:
          <el-input-number v-model="data.robotNumObject.type" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginR10" placeholder="下注模式" clearable :controls="false" />
          机器人数量:
          <el-input-number v-model="data.robotNumObject.num" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginR10" placeholder="机器人数量" clearable :controls="false" />
          百分比:
          <el-input-number v-model="data.robotNumObject.pattern" :min="0" :max="100" :precision="0"
            class="width150" placeholder="百分比" clearable :controls="false" /><span class="marginR10">%</span>
          下注额度模式:
          <el-input-number v-model="data.robotNumObject.patternNum" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginR10" placeholder="下注额度模式" clearable :controls="false" />
          跳机模式:
          <el-input-number v-model="data.robotNumObject.jump" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginR10 marginT5" placeholder="跳机模式" clearable :controls="false" />
          概率:
          <el-input-number v-model="data.robotNumObject.chance" :min="0" :max="100" :precision="0"
            class="width150 marginT5" placeholder="概率" clearable :controls="false" /><span class="marginR30">%</span>
          下注模式:
          <el-input-number v-model="data.robotNumObject.type2" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginR10 marginT5" placeholder="下注模式" clearable :controls="false" />
          机器人数量:
          <el-input-number v-model="data.robotNumObject.num2" :min="0" :max="99999999999999999999" :precision="0"
            class="width150 marginT5" placeholder="机器人数量" clearable :controls="false" />
          <div class="flexWrap marginT5" v-for="(item, index) in data.robotNumList" :key="index">
            下注模式:
            <el-input-number v-model="item.pattern" :min="0" :max="99999999999999999999" :precision="0" class="width120"
              placeholder="下注模式" clearable :controls="false" />
            下注额度模式:
            <el-input-number v-model="item.patternNum" :min="0" :max="99999999999999999999" :precision="0"
              class="width120" placeholder="下注额度模式" clearable :controls="false" />
            跳机模式:
            <el-input-number v-model="item.jump" :min="0" :max="99999999999999999999" :precision="0" class="width120"
              placeholder="跳机模式" clearable :controls="false" />
            概率:
            <el-input-number v-model="item.chance" :min="0" :max="100" :precision="0" class="width120" placeholder="概率"
              clearable :controls="false" />%
          </div>
        </form-item>
        <form-item title="头像昵称更换比例" :pass="true" value="a_robot_headname">
          <el-input-number v-model="data.a_hundred_other_details.a_robot_headname" :min="0" :max="100"
            placeholder="头像昵称更换比例" clearable controls-position="right" />%
        </form-item>
        <form-item title="有玩家未跳时坠机比例" :pass="true" value="a_hundred_crashproportion">
          <div class="flexWrap" v-for="(item, index) in data.crashproportionList" :key="index">
            下限百分比:
            <el-input-number v-model="item.min" :min="0" :max="100" :precision="0" class="width120"
              placeholder="下限百分比" clearable :controls="false" /><span class="marginR20">%</span>
              
            上限百分比:
            <el-input-number v-model="item.max" :min="0" :max="100" :precision="0" class="width120" placeholder="上限百分比"
              clearable :controls="false" />%
          </div>
        </form-item>
        <form-item title="机器人跳机" :pass="true" value="a_robot_leave" :subtract="props.showDisable?false:true" @addItem="addRobotLeaveL"
          @reduceItem="reduceRobotLeaveL" style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.robotLeaveList" :key="index">
            类型:
            <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="类型" clearable :controls="false" />
            权重:
            <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="权重" clearable :controls="false" />
            递增权重:
            <el-input-number v-model="item.increasing" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="递增权重" clearable :controls="false" />
            判定次数:
            <el-input-number v-model="item.num" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="判定次数" clearable :controls="false" />
            判定周期:
            <el-input-number v-model="item.time" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10 marginT5" placeholder="判定周期" clearable :controls="false" />
            下限Min(毫秒):
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10 marginT5" placeholder="下限Min(毫秒)" clearable :controls="false" />
            上限Max(毫秒):
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginT5" placeholder="上限Max(毫秒)" clearable :controls="false" />
          </div>
        </form-item>
        <form-item title="游戏下注" :pass="true" value="a_hundred_stake">
          <div class="flexWrap margin5" v-for="(item, index) in data.gameStakeList" :key="index">
            刻度:
            <el-input-number v-model="item.scale" :min="0" :max="99999999999999999999" :precision="4"
              class="width120 marginR10" placeholder="刻度" clearable :controls="false" />
            下注下限:
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="下注下限" clearable :controls="false" />
            下注上限:
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="下注上限" clearable :controls="false" />
            默认值:
            <el-input-number v-model="item.default" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR10" placeholder="默认值" clearable :controls="false" />
            赢上限额度:
            <el-input-number v-model="item.winMax" :min="0" :precision="0" :max="99999999999999999999"
              class="width150 marginR15 marginT5" placeholder="赢上限额度" clearable :controls="false" />
            快捷下注1:
            <el-input-number v-model="item.fast1" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR15 marginT5" placeholder="快捷下注1" clearable :controls="false" />
            快捷下注2:
            <el-input-number v-model="item.fast2" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR15 marginT5" placeholder="快捷下注2" clearable :controls="false" />
            快捷下注3:
            <el-input-number v-model="item.fast3" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginR15 marginT5" placeholder="快捷下注3" clearable :controls="false" />
            快捷下注4:
            <el-input-number v-model="item.fast4" :min="0" :max="99999999999999999999" :precision="0"
              class="width150 marginT5" placeholder="快捷下注4" clearable :controls="false" />
          </div>
        </form-item>
        <form-item title="初始水位" :pass="true" value="a_hundred_poolstart">
          <el-input-number v-model="data.a_hundred_other_details.a_hundred_poolstart" :min="-99999999999999999999"
            :max="99999999999999999999" placeholder="初始水位" clearable controls-position="right" />
        </form-item>
        <form-item title="水位配置" value="a_hundred_pool" :subtract="props.showDisable?false:true" @addItem="addPool" @reduceItem="reducePool"
          style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.poolList" :key="index">
            水位下限:
            <el-input-number v-model="item.min" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
              class="width120 marginR5" placeholder="水位下限" clearable :controls="false" />
            水位上限:
            <el-input-number v-model="item.max" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
              class="width120 marginR5" placeholder="水位上限" clearable :controls="false" />
            权重:
            <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR5" placeholder="权重" clearable :controls="false" />
            押赢比例:
            <el-input-number v-model="item.winRatio" :min="0" :max="100" :precision="0" class="width120"
              placeholder="押赢比例" clearable :controls="false" /><span class="marginR5">%</span>
            押输比例:
            <el-input-number v-model="item.loseRatio" :min="0" :max="100" :precision="0"
              class="width120 marginT5" placeholder="押输比例" clearable :controls="false" /><span class="marginR5">%</span>
            输上限额度:
            <el-input-number v-model="item.lose" :min="-99999999999999999999" :max="99999999999999999999" :precision="4"
              class="width120 marginT5" placeholder="输上限额度" clearable :controls="false" />
          </div>
        </form-item>
        <form-item title="机器人下注" value="a_robot_hundred_stake" :subtract="props.showDisable?false:true" @addItem="addRobotStake"
          @reduceItem="reduceRobotStake" style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.robotStakeList" :key="index">
            下注类型:
            <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR5" placeholder="下注类型" clearable :controls="false" />
            下注概率:
            <el-input-number v-model="item.chance" :min="0" :max="100" :precision="0" class="width120"
              placeholder="下注概率" clearable :controls="false" /><span class="marginR5">%</span>
            次数:
            <el-input-number v-model="item.num1" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR20" placeholder="次数One" clearable :controls="false" />
            比例:
            <el-input-number v-model="item.ratio1" :min="0" :max="100" :precision="0" class="width120"
              placeholder="比例One" clearable :controls="false" /><span class="marginR10">%</span>
            次数:
            <el-input-number v-model="item.num2" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginR12 marginT5" placeholder="次数Two" clearable :controls="false" />
            比例:
            <el-input-number v-model="item.ratio2" :min="0" :max="100" :precision="0"
              class="width120 marginT5" placeholder="比例Two" clearable :controls="false" /><span class="marginR12">%</span>
          </div>
        </form-item>
        <form-item title="下注额度" value="a_robot_hundred_stake_amount" :subtract="props.showDisable?false:true" @addItem="addRobotAmount"
          @reduceItem="reduceRobotAmount" style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.robotAmountList" :key="index" style="position: relative">
            额度类型:
            <el-input-number v-model="item.type" :min="0" :max="99999999999999999999" :precision="0"
              class="width120 marginB5" placeholder="额度类型" clearable :controls="false" />
            <div class="marginB5 flex" v-for="(second, two) in item.betAmount" :key="two">
              额度下限:
              <el-input-number v-model="second.min" :min="0" :max="99999999999999999999" :precision="4"
                class="width130 marginR2" placeholder="额度下限" clearable :controls="false" />
              额度上限:
              <el-input-number v-model="second.max" :min="0" :max="99999999999999999999" :precision="4"
                class="width130 marginR2" placeholder="额度上限" clearable :controls="false" />
              概率:
              <el-input-number v-model="second.chance" :min="0" :max="100" :precision="0" class="width110 marginR2"
                placeholder="概率" clearable :controls="false" />%
              去尾概率:
              <el-input-number v-model="second.tailChance" :min="0" :max="100" :precision="0" class="width120"
                placeholder="去尾概率" clearable :controls="false" />%
              <div class="add-btn marginL10" v-show="item.betAmountIndex == two && !props.showDisable" @click="addStakeAmount(index, item)">+</div>
              <div class="reduce-btn marginL5" v-show="item.betAmountIndex == two && !props.showDisable" @click="reduceStakeAmount(index, item)">-</div>
            </div>
          </div>
        </form-item>
        <form-item title="下注手数" value="a_hundred_num" :subtract="props.showDisable?false:true" @addItem="addRobotHundred"
          @reduceItem="reduceRobotHundred" style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.robotHundredList" :key="index">
            时间起点:
            <el-input-number v-model="item.start" :min="0" :max="99999999999999999999" :precision="0"
              class="width110 marginR5" placeholder="时间起点" clearable :controls="false" />
            时间止点:
            <el-input-number v-model="item.end" :min="0" :max="99999999999999999999" :precision="0"
              class="width110 marginR5" placeholder="时间止点" clearable :controls="false" />
            随机下限:
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="0"
              class="width110 marginR5" placeholder="随机下限" clearable :controls="false" />
            随机上限:
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="0"
              class="width110 marginR5" placeholder="随机上限" clearable :controls="false" />
          </div>
        </form-item>
        <form-item title="无人倍数" value="a_hundred_noperson" :subtract="props.showDisable?false:true" @addItem="addNoperson"
          @reduceItem="reduceNoperson" style="height: auto; position: relative">
          <div class="flexWrap margin5" v-for="(item, index) in data.nopersonList" :key="index">
            倍数下限:
            <el-input-number v-model="item.min" :min="0" :max="99999999999999999999" :precision="4"
              class="width130 marginR15" placeholder="倍数下限" clearable :controls="false" />
            倍数上限:
            <el-input-number v-model="item.max" :min="0" :max="99999999999999999999" :precision="4"
              class="width130 marginR15" placeholder="倍数上限" clearable :controls="false" />
            权重:
            <el-input-number v-model="item.weight" :min="0" :max="99999999999999999999" :precision="0" class="width120"
              placeholder="权重" clearable :controls="false" />
          </div>
        </form-item>
      </el-form>
    </div>
    <div class="flexRightDetween marginT20" v-show="!props.showDisable">
      <div>
        <el-button type="info" @click="onHideDetails">取 消</el-button>
        <el-button type="primary" @click="gameSet(ruleFormRef)">确 定</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, computed, unref } from 'vue'
import { ElMessage } from 'element-plus'
import type { FormInstance, FormRules } from 'element-plus'
import { getOperatorAircraft, editAircraft, getPool, editPool } from '@/api/game'
import FormItem from '@/components/FormItem/FormItem.vue'
import { BigWan, BigTimeWan } from '@/utils/math'
import { throttle } from '@/utils/index'
import type {
  Normalmode,
  RobotNumObject,
  RobotNumList,
  RobotStake,
  GameStake,
  RobotLeave,
  RobotAmount,
  RobotHundred,
  Noperson,
  RobotPool
} from './gameType'
import { useStore } from '@/stores/index'
const indexStore = useStore()

const props = defineProps({
  show: {
    type: Boolean,
    default: () => {
      return false
    }
  },
  showDisable: {
    type: Boolean,
    default: () => {
      return false
    }
  },
  checkedItem: {
    type: Object,
    default: () => {
      return {}
    }
  }
})

watch(
  () => [props.checkedItem, props.show],
  async (value, show) => {
    if (value) {
      Object.assign(data, props.checkedItem)
    }
    if (!show[1]) {
      chooseOperator(props.checkedItem.agent_id,props.checkedItem.game_id) // 获取运营商配置
    }
  },
)

const data = reactive({
  id: 0,
  game_id: 0,
  agent_id: 0,
  game_name: '',
  operated_id: indexStore.agentArray[0].value,
  a_hundred_num: 0, // 房间最大人数
  a_hundred_pump: 0, // 抽水比例
  pool: 0,// 游戏水位
  a_hundred_other_details: {
    a_hundred_pool: '', // 水位配置(水位下限，水位上限，系统赢权重，赢押注比例，输押注比例，输上限额度......)
    a_hundred_poolstart: 0, // 初始水位
    a_hundred_profitmargin: 0, // 利润率
    a_hundred_supermoderate: 0, // 超长模式触发概率
    a_hundred_normalmode: '', // 正常模式玩家跑光后延长百分比(倍数下限，倍数上限，延长百分比下限，延长百分比上限......)*****
    a_hundred_supermode: '', // 超长模式玩家跑光后随机倍数(下限，上限)
    a_hundred_stake: '', // 游戏下注(刻度，最小值，最大值，默认值，最大赢取额度,快捷下注1，快捷下注2，快捷下注3，快捷下注4......)*****
    a_robot_hundred_num: '', // 机器人数量(机器人类型1，数量，下注模式，下注额度模式，跳机模式，概率;......)*****
    a_robot_hundred_stake: '', // 机器人下注(下注类型1；下注概率;次数1，比例;次数2，比例-......)*****
    a_robot_hundred_stake_amount: '', // 机器人下注额度(额度下限，额度上限，概率，去尾概率；.....) *****
    a_robot_leave: '', // 机器人跳机(跳机类型1，初始跳机权重，每次判定后递增权重，必走判定次数，判定周期【毫秒】，判定成功后延迟下限【毫秒】，判定成功后上限【毫秒】)*****
    a_robot_headname: 0, // 头像昵称更换比例
    a_hundred_num: '', // 下注手数(显示时间起点，显示时间止点，随机范围下限，随机范围上限；.....)
    a_hundred_noperson: '', // 无人倍数(随机倍数下限，随机倍数上限，权重；.....)
    a_hundred_crashproportion: '' // 有玩家未跳时坠机比例(坠机比例下限，坠机比例上限)
  },
  crashproportionList: [{ min: 0, max: 0 }], // 有玩家未跳时坠机比例
  supermodeList: [{ min: 0, max: 0 }], // 超长模式玩家跑光后随机倍数
  normalmodeList: [] as Normalmode[], // 正常模式玩家跑光后延长百分比
  robotNumObject: {} as RobotNumObject,
  robotNumList: [] as RobotNumList[], // 机器人数量
  gameStakeList: [] as GameStake[], // 游戏下注
  robotLeaveList: [] as RobotLeave[], //机器人跳机
  robotStakeList: [] as RobotStake[], // 机器人下注
  robotAmountList: [ // 机器人下注额度
    { type: 0, betAmount: [] as RobotAmount[], betAmountIndex: 0 }
  ],
  robotHundredList: [] as RobotHundred[], // 下注手数
  nopersonList: [] as Noperson[], // 无人倍数
  poolList: [] as RobotPool[], // 水位配置
})

// 选择运营商
const chooseOperator = async (id: number,game_id: number) => {
  let res = await getOperatorAircraft({ agent_id: id,game_id: game_id });
  Object.assign(data, res.data)
  if(data.agent_id){
    let agent = await getPool({ agent_id: id, game_id: props.checkedItem.game_id });
    data.pool = BigWan(agent.data ? agent.data : 0)
  }
}

const ruleFormRef = ref<FormInstance>()
const rules = reactive<FormRules<typeof data>>({
  a_hundred_num: [{ required: true, message: '请输入房间最大人数', trigger: 'blur' }],
  a_hundred_pump: [{ required: true, message: '请输入抽水比例', trigger: 'blur' }]
})
const gameSet = throttle(async (formEl: FormInstance | undefined) => {
  if (!formEl) return
  await formEl.validate(async (valid, fields) => {
    if (valid) {
      let res = await editAircraft(data);
      if(data.agent_id){
        let agent = await editPool({
          agent_id:data.agent_id,
          game_id:data.game_id,
          pool:BigTimeWan(data.pool)
        });
      }
      ElMessage.success('修改成功')
      onHideDetails()
    }
  })
}, 3000)

// 重置
const emit = defineEmits(['onHideDetails'])
const onHideDetails = () => {
  document.body.style.overflow = '';
  document.body.style.paddingRight = ''
  emit('onHideDetails', false)
}

// 正常模式玩家跑光后延长百分比
const addNormalmode = () => {
  data.normalmodeList.push({ min: 0, max: 0, percentMin: 0, percentMax: 0 })
}
const reduceNormalmode = () => {
  data.normalmodeList.splice(data.normalmodeList.length - 1, 1)
}

// 机器人数量
const addRobotNum = () => {
  data.robotNumList.push({ pattern: 0, patternNum: 0, jump: 0, chance: 0 })
}
const reduceRobotNum = () => {
  data.robotNumList.splice(data.robotNumList.length - 1, 1)
}

// 机器人下注
const addRobotStake = () => {
  data.robotStakeList.push({ type: 0, chance: 1, num1: 0, ratio1: 1, num2: 0, ratio2: 1 })
}
const reduceRobotStake = () => {
  data.robotStakeList.splice(data.robotStakeList.length - 1, 1)
}

// 机器人跳机
const addRobotLeaveL = () => {
  data.robotLeaveList.push({ type: 0, weight: 0, increasing: 0, num: 0, time: 0, min: 0, max: 0 })
}
const reduceRobotLeaveL = () => {
  data.robotLeaveList.splice(data.robotLeaveList.length - 1, 1)
}

// 下注额度
const addRobotAmount = () => {
  if (!data.robotAmountList.length) {
    data.robotAmountList.push({ type: 1, betAmount: [{ min: 0, max: 0, chance: 0, tailChance: 0 }], betAmountIndex: 0 })
  } else {
    data.robotAmountList.push({ type: data.robotAmountList[data.robotAmountList.length - 1].type + 1, betAmount: [{ min: 0, max: 0, chance: 0, tailChance: 0 }], betAmountIndex: 0 })
  }
}
const reduceRobotAmount = () => {
  data.robotAmountList.splice(data.robotAmountList.length - 1, 1)
}
const addStakeAmount = (index: number, item: any) => {
  item.betAmountIndex++
  data.robotAmountList[index].betAmount.push({ min: 0, max: 0, chance: 0, tailChance: 0 })
}
const reduceStakeAmount = (index: number, item: any) => {
  item.betAmountIndex--
  data.robotAmountList[index].betAmount.splice(data.robotAmountList[index].betAmount.length - 1, 1)
}


// 下注手数
const addRobotHundred = () => {
  data.robotHundredList.push({ start: 0, end: 1, min: 0, max: 1 })
}
const reduceRobotHundred = () => {
  data.robotHundredList.splice(data.robotHundredList.length - 1, 1)
}

// 无人倍数
const addNoperson = () => {
  data.nopersonList.push({ min: 0, max: 1, weight: 0 })
}
const reduceNoperson = () => {
  data.nopersonList.splice(data.nopersonList.length - 1, 1)
}

// 水位配置
const addPool = () => {
  data.poolList.push({ min: 0, max: 1, weight: 0, winRatio: 0, loseRatio: 0, lose: 0 })
}
const reducePool = () => {
  data.poolList.splice(data.poolList.length - 1, 1)
}
</script>

<style scoped lang="scss">
.add-btn {
  position: absolute;
  left: 185px;
  top: 8px;
  background-color: green;
}

.reduce-btn {
  position: absolute;
  left: 225px;
  top: 8px;
  background-color: #e6a23c;
}
</style>
